package com.emokili.ewa.frame.controller.v1;

import com.emokili.ewa.common.utils.R;
import com.emokili.ewa.core.frame.entity.FrameEntity;
import com.emokili.ewa.core.frame.entity.PlayListSettingEntity;
import com.emokili.ewa.core.frame.service.FrameService;
import com.emokili.ewa.core.frame.service.PlayListSettingService;
import com.emokili.ewa.core.frame.vo.FrameInfoVo;
import com.emokili.ewa.frame.service.SettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("v1/frame")
public class SettingController {

    @Autowired
    private FrameService frameService;
    @Autowired
    private SettingService settingService;

    @RequestMapping("/setting/{serialNumber}")
    @ResponseBody
    public R setting(@PathVariable String serialNumber){
        FrameEntity frameSetting = settingService.getFrameSetting(serialNumber);
        PlayListSettingEntity playListSetting = settingService.getPlayListSetting(serialNumber);
        return R.ok().put("frameSetting",frameSetting).put("playListSetting",playListSetting);
    }

    @PostMapping("/update")
    @ResponseBody
    public R update(@RequestBody FrameInfoVo frameInfoVo){
        settingService.update(frameInfoVo);
        return R.ok();
    }
}
